//
//  Queue.m
//  Tank For IPhone
//
//  Created by 奕 朱 on 11-3-2.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Queue.h"


@implementation Queue

- (id) init {
	
	if (self = [super init]) {
		objects = [[NSMutableArray alloc] init];
	}
	return self;
	
}

- (id) poll {
	
	id object = nil;
	if ([objects count] > 0) {
		object = [objects objectAtIndex:0];
		[objects removeObjectAtIndex:0];
	}
	return object;
	
} 

- (void) offer:(id)object {
	[objects addObject: object];
}

- (int) size {
	return [objects count];
}

- (id) getObject:(int)index {
	return [objects objectAtIndex: index];
}

- (void) dealloc {
	
	[objects release];
	[super dealloc];
	
}

@end
